package com.alex.statistics.pojo.request.spatialAnalysis;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Data
@Schema(description = "全局Moran's I空间自相关分析请求参数（GeoJSON输入）")
public class GlobalMoranIRequest {

    @Schema(description = "GeoJSON格式的空间数据（FeatureCollection类型，包含面状或点状要素）",
            required = true)
    private String geoJson;

    @Schema(description = "GeoJSON中用于分析的数值属性字段名（如'population'、'gdp'）",
            required = true, example = "value")
    private String valueField;

    @Schema(description = "空间权重矩阵类型",
            required = true)
    private WeightType weightType;

    @Schema(description = "KNN权重的邻居数量（仅当weightType=KNN时必填）",
            example = "4")
    private Integer knnK;

    @Schema(description = "距离阈值（仅当weightType=DISTANCE_THRESHOLD时必填，单位与GeoJSON坐标一致）",
            example = "1000.0")
    private Double distanceThreshold;

    @Schema(description = "蒙特卡洛置换检验次数（用于显著性检验，默认999次）",
            example = "999", defaultValue = "999")
    private Integer permutations = 999;

    @Schema(description = "是否返回详细统计量（期望、方差、Z值）",
            example = "true", defaultValue = "true")
    private Boolean includeStats = true;

    @Schema(description = "空间权重矩阵类型枚举")
    public enum WeightType {
        @Schema(description = "K最近邻：每个要素关联距离最近的K个要素")
        KNN,
        @Schema(description = "距离阈值：距离≤阈值的要素视为关联")
        DISTANCE_THRESHOLD,
        @Schema(description = "Queen邻接（面状要素）：共享边界或顶点的要素视为关联")
        QUEEN,
        @Schema(description = "Rook邻接（面状要素）：仅共享边界的要素视为关联")
        ROOK
    }

    private GlobalMoranIRequest() {}

    public static GlobalMoranIRequest createGlobalMoranIRequest() {
        return new GlobalMoranIRequest();
    }
}